package com.hdax.dm.mappers;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hdax.dm.item.DmCinema;
import com.hdax.dm.item.Item;
import com.hdax.dm.item.ItemType;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

import java.util.List;

public interface ItemMapper extends BaseMapper<Item> {
    /**
     * 热门商品
     * @return
     */
    @Select(value = {
            "<script>",
            "SELECT * FROM dm_item",
                "<where>",
                    "<if test=\"itemType1Id!=-1\"> AND itemType1Id=#{itemType1Id}</if>",
                    "<if test=\"isBanner!=-1\"> AND isBanner=#{isBanner}</if>",
                "</where>",
            " ORDER BY startTime DESC",
            " LIMIT 5",
            "</script>"

    })
    List<Item> hotItems(@Param("itemType1Id") Long itemType1Id, @Param("isBanner") Long isBanner);
    @Select(value = {
            "<script>",
            "SELECT * FROM dm_item",
            " ORDER BY startTime DESC",
            " LIMIT 6",
            "</script>"
    })
    List<Item> sellItems();

    //获取dm_item_type表值
    @Select("SELECT * FROM dm_item_type WHERE parent = 0")
    List<ItemType> typeItems();

    //获取dm_cinema表值
    @Select(value = {
            "<script>",
            "SELECT * FROM dm_cinema",
                "<where>",
                "<if test=\"cinemaId!=-1\"> AND id=#{cinemaId}</if>",
                "</where>",
            "</script>"
    })
    List<DmCinema> dmCinemas(@Param("cinemaId") Long cinemaId);
}
